<?php

class ActivityModel extends Model{
    protected $tableName = 'atv_main_info';
    protected $fields = array(
        'id',
        'atv_subj',
        'org_id',
        'atv_start_time',
        'atv_end_time',
        'sign_up_start_time',
        'sing_up_end_time',
        'atv_name',
        'atv_desc',
        'atv_type',
        'atv_city_id',
        'atg_uni_id',
        'poster_id',
        'upper_bound',
        'sms_time',
        'page_view',
        'thump_up_count',
        '_pk' => 'id', '_autoinc' => true
    );

    protected $_map = array(
        'orgId' => 'org_id',//useless

        'atvId'          => 'id',
        'atvSubj'        => 'atv_subj',
        'atvName'        => 'atv_name',
        'atvStartTime'   => 'atv_start_time',
        'atvEndTime'     => 'atv_end_time',
        'signUpStartTime'=> 'sign_up_start_time',
        'singUpEndTime'  => 'sing_up_end_time',
        'atvDesc'        => 'atv_desc',
        'atvType'        => 'atv_type',
        'atvCity'        => 'atv_city_id',
        'atvUni'         => 'atg_uni_id',
        //'atvAddress'     => '',
        'posterId'       => 'poster_id',
        'upperBound'     => 'upper_bound',
    );

    //转换结果集到指定的别名
    public function fieldToOutputContent($dataList){
        $fieldMap = array(
            'id'                    =>	 'atvId'            ,
            'atv_subj'             =>  'atvSubj'         ,
            'atv_name'             =>  'atvName'         ,
            'atv_start_time'      =>  'atvStartTime'    ,
            'atv_end_time'        =>  'atvEndTime'      ,
            'sign_up_start_time' =>  'signUpStartTime' ,
            'sign_up_end_time'   =>  'signUpEndTime'   ,
            'atv_desc'            =>  'atvDesc'         ,
            'atv_type'            =>  'atvType'         ,
            'atv_city_id'        =>  'atvCity'         ,
            'atg_uni_id'         =>  'atvUni'          ,
            //'atvAddress'         =>  'atvAddress'      ,//该字段数据库中没有
            'poster_id'           =>  'posterId'        ,
            'upper_bound'         =>  'upperBound'      ,
            'sms_time'            =>  'smsTime'         ,
            'page_view'           =>  'pageView'        ,
            'thump_up_count'     =>  'shareCount'      ,
        );
        $resultList = array();
        foreach ($dataList as $dataOne){
            $resultOne = array();
            foreach ($dataOne as $key => $value) {
                $newFieldName = $fieldMap[$key];
                $resultOne[$newFieldName] = $value;
            }
            array_push($resultList, $resultOne);
        }
        return $resultList;
    }
}


?>